<?php

namespace App\Models\API;

use Illuminate\Database\Eloquent\Model;

class ActivityJoin extends Model
{
    public function activity()
    {
    	return $this->belongsTo('App\Models\API\Activity');
    }

    /**
     * 查看用户是否已经加入活动
     * @return 0 1
     */
    public static function isJoined($activityId, $userId)
    {
    	$activityJoin = new ActivityJoin;

    	$res = $activityJoin->where([
    		['activity_id', $activityId],
    		['user_id', $userId],
    	])->first();

    	return count($res);
    }
}
